MPEGDecoder.dll for AviSynth
(Version 1.31)

By Nic

Introduction

This DLL lets you load VOB/MPEG-2 Program/Transport files to be loaded directly into Avisynth.
i.e. no need for creating a d2v file.

A Sample AVISynth Script looks like this:

LoadPlugin("MPEGDecoder.dll")
MPEGSource("d:\kiss\kiss.vob")

This avs file can now be loaded into VDub/etc.
(Requirements: SSE MMX, i.e. probably at least a Pentium3 to run)


Parameters

The other parameters for 'MPEGSource' are as follows:
MPEGSource(PathName(string), TotalFramesofFile(integer), TransportStream video PID (in hex)(string))

  • TotalFramesofFile:


  • Because MPEGSource has to make a quick calculation of how many frames the MPEG2 file has, you can specify how many frames you want MPEGSource to tell AVISynth the file has.
    e.g.
    MPEGSource("d:\kiss\kiss.vob", 1000)
    Will load just 1000 frames from kiss.vob

    You can use -1 in this parameter for a far slower, more accurate calculation of the frame count
    Use 0 to use the normal automatic search
    Now has a -2 search, this uses DirectShow to find the length of the video, this may well be more accurate than my search. It doesn't require a MPEG decoder filter.

  • TransportStream video PID:


  • MPEGSource also supports Transport Streams, but the video PID must be supplied
    e.g.
    MPEGSource("d:\mp2transcode\modern.mpg", 0, "0x1023")
    The TotalFramesofFile = 0 will auto calculate the number of frames
    "0x1023" = will use the PID of 0x1023, please remember the qutotation marks

  • Raw Video


  • If you have a MPEG-2 file that just has raw packets, then put into the TransportPID parameter "raw"
    this will set the filter to decode raw packets (as might sometimes be found in .m2v files)
    If you have a MPEG-1 video that is a ES stream enable "raw" as well (with this setting seeking will fail)

  • Encrypted Vobs


  • You can now read encrypted vobs straight from the DVD using the "decss" command in the transport
    PID parameter.
    e.g.
    MPEGSource("g:\video_ts\VTS_02_01.vob", -2, "decss")

  • Joining Multiple Files


  • You can now join multiple files together by doing:
    MPEGSource("e:\modern.mpg")
    MPEGSource("e:\video_ts\vts_05_01.vob + e:\video_ts\vts_05_02.vob + etc.vob")

    or you can use a list file (.lst file, like VStrip uses)
    MPEGSource("c:\Film.lst")
    (list files contain just the names of the files to be loaded, the files must have a carriage return
    seperator & the list file must have the extension .lst)


    NicCrop

    A simple crop function to take the crop parameters from DVD2AVI or VDub for simple cropping
    its defined as NicCrop(left, right, top, bottom)
    e.g.
    LoadPlugin("MPEGDecoder.dll")
    MPEGSource("d:\mp2transcode\fd1.m2v", 0, "raw")
    NicCrop(8,10,64,68)
    will crop 8 off the left handside
    10 off the right handside
    64 off the top &
    68 off the button


    Misc/Notes

  • Bugs/Pro's/Con's


  • BUG: !There is no proper seeking in the file, it decodes just one frame after another! (This will be updated) This means if loading into VDub for encoding, dont drag the slider & look thru the film before trying to encode. If you want to browse thru the file in VDub then reload the file before encoding.

    PRO: Its fast, faster decoding than normal MPEG2DEC.DLL(MPEG2Source). This speeds up encoding :)


    Credits

    The MPEG2 decoding library is based on libmpeg2.sf.net (Michel Lespinasse , Aaron Holtzman )

    iDCT is the modified Intel one by Peter Gubanov (as used in DVD2AVI)

    ColorSpace code comes from the XviD MPEG-4 project (www.xvid.org) (Michael Militzer, Peter Ross, edgomez)

    Ive pinched the way this doc looks from Decomb 3.8's documentation (by Donald Graft - http://shelob.mordor.net/dgraft/ )

    Changelog as of 1.3

    1.31
    Re-Added (& fixed) .lst
    Other minor bugfixes

    1.3
    Added DirectShow file length size using -2 in the number of frames field. Recommended.
    Added DeCSS support, code based on my OpenDVD.dll plugin for DVD2AVI_NIC
    Added MPEG-1 support, always use -2 to find the length of the file

    All code is GPL!

    email: nic@nic.dnsalias.com